using System;
using System.Collections.Generic;
using System.Text;
using CodeStory.Core.UI;

namespace CodeStory.Gallery.Portlets
{
	public class GallerySettingEditor : Portlet
	{
		protected global::CodeStory.WebControls.PropertyGrid objectPropertyGrid;

		protected global::System.Web.UI.WebControls.Button btnSave;

		protected override void OnInit(EventArgs e) {
			Load += new EventHandler(GallerySettingEditor_Load);
			btnSave.Click += new EventHandler(ButtonSave_Click);
			base.OnInit(e);
		}

		private void ButtonSave_Click(object sender, EventArgs e) {
			GallerySetting obj = objectPropertyGrid.SelectedObject as GallerySetting;
			if (obj != null) {
				obj.Save();
				GallerySetting.Current.Reset();
			}
		}

		void GallerySettingEditor_Load(object sender, EventArgs e) {
			if (!IsPostBack) {
				BindObject();
			}
		}

		private void BindObject() {
			GallerySetting setting = GallerySetting.Current;
			objectPropertyGrid.SelectedObject = setting;
			objectPropertyGrid.DataBind();
		}
	}
}
